package context.render.tiu;

import context.render.tiu.sampler.Sampler;
import context.render.tiu.texture.Texture;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL33;

public class TIU
{
    
    private int mID;
    
    private Texture rTexture;
    
    private Sampler rSampler;
    
    
    public TIU(int aID)
    {
        this.mID = aID;
        this.rTexture = null;
        this.rSampler = null;
    }
    
    
    public void bind(Texture aTexture)
    {
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + this.mID);
        Texture.bind(aTexture);
        this.rTexture = aTexture;
    }
    
    public void bind(Sampler aSampler)
    {
        GL33.glBindSampler(this.mID, aSampler.mID);
    }
    
    
    public boolean isValid()
    {
        return (
            this.rTexture != null && 
            this.rSampler != null
        );
    }
    
    
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append("TIU\n   Texture: ");
        sb.append(this.rTexture);
        sb.append("\n   Sampler: ");
        sb.append(this.rSampler);
        return sb.toString();
    }
    
}
